/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef __MaCI_ParameterMainFrame__
#define __MaCI_ParameterMainFrame__

/**
@file
Subclass of MainFrame, which is generated by wxFormBuilder.
*/

#include "MaCI_Parameter_GUI.h"
#include "MaCI_ParameterAbout_Dialog.h"
#include "ParameterClient.hpp"
#include "Component.hpp"
#include "owndebug.h"
#include "ownutils.h"
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(MY_EVENT_UPDATESERVICELIST, -1)
END_DECLARE_EVENT_TYPES();
/** Implementing MainFrame */
class MaCI_ParameterMainFrame :  private gim::CSync,
                                 private gim::CThread,
                                 public MainFrame,
                                 public Gimbo::CComponent
{
  DECLARE_EVENT_TABLE();
protected:
	// Handlers for MainFrame events.
	void OnQuit( wxCommandEvent& event );
	void OnAbout( wxCommandEvent& event );
	void OnUpdateList( wxCommandEvent& event );
	void OnSendValues( wxCommandEvent& event );
	void OnListItemSelected( wxCommandEvent& event );
        void OnParameterListSelected( wxListEvent& event );
        void OnServiceAssignment(const Gimbo::TServiceAssignmentList &aServiceList);  
public:
	/** Constructor */
	MaCI_ParameterMainFrame( wxWindow* parent );
        bool Initialize(gimi::GIMI *aGimiPtr, int aGimboID, int aReportID);
        void Deinitialize(void);



 private:
        void DisconnectServices(void);
        bool ConnectServices(void);
        int ThreadFunction(const int aThreadNumber);
        void UpdateServiceList(wxCommandEvent &aEvent);
        void UpdateParameterList();
        wxWindow* iParent;
        Gimbo::TServiceAssignmentList iServiceList;
        bool iServiceListUpdated;
        gimi::GIMI *iGIMIPtr;
        std::vector<MaCI::Parameter::CParameterClient *> iParameterClientArray;
        bool iThreadRunning;
        std::string iVersionNumber;
        Gimbo::TServiceAssignmentList iNewServiceList;
        MaCI::MaCICtrl::CMaCICtrlClient *iMaCICtrlClient;
};

#endif // __MaCI_ParameterMainFrame__
